this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(t,e,n,o,i,a,s,r){"use strict";var u,l,c,p,d;function y(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function g(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?y(Object(n),!0).forEach((function(e){babelHelpers.defineProperty(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var m=function(t){babelHelpers.inherits(e,t);function e(t){var o;babelHelpers.classCallCheck(this,e);o=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(e).call(this));o.setEventNamespace("BX.Landing.UI.Component.ListItem");o.subscribeFromOptions(r.fetchEventsFromOptions(t));o.onEditButtonClick=o.onEditButtonClick.bind(babelHelpers.assertThisInitialized(o));o.onRemoveButtonClick=o.onRemoveButtonClick.bind(babelHelpers.assertThisInitialized(o));o.onFormChange=o.onFormChange.bind(babelHelpers.assertThisInitialized(o));o.options=g({},t);o.cache=new n.Cache.MemoryCache;if(n.Type.isDomNode(o.options.appendTo)){o.appendTo(o.options.appendTo)}else if(n.Type.isDomNode(o.options.prependTo)){o.prependTo(o.options.prependTo)}if(n.Type.isArrayFilled(o.options.actions)){o.setActionsButtons(babelHelpers.toConsumableArray(o.options.actions))}if(o.options.error){n.Dom.addClass(o.getLayout(),"landing-ui-error")}return o}babelHelpers.createClass(e,[{key:"setActionsButtons",value:function t(e){this.cache.set("actionsButtons",e)}},{key:"getActionsButtons",value:function t(){return this.cache.get("actionsButtons",[])}},{key:"appendTo",value:function t(e){n.Dom.append(this.getLayout(),e)}},{key:"prependTo",value:function t(e){n.Dom.prepend(this.getLayout(),e)}},{key:"getDragButtonLayout",value:function t(){return this.cache.remember("dragButtonLayout",(function(){var t=new s.IconButton({type:s.IconButton.Types.drag,title:i.Loc.getMessage("LANDING_UI_COMPONENT_LIST_ITEM_DRAG_TITLE"),style:{position:"absolute",left:"1px",width:"8px"}});return t.getLayout()}))}},{key:"getTitleLayout",value:function t(){var e=this;return this.cache.remember("titleLayout",(function(){return n.Tag.render(u||(u=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-component-list-item-text-title">',"</div>\n\t\t\t"])),n.Text.encode(e.options.title))}))}},{key:"setTitle",value:function t(e){this.getTitleLayout().textContent=e}},{key:"getTitle",value:function t(){return this.getTitleLayout().innerText}},{key:"getDescriptionLayout",value:function t(){var e=this;return this.cache.remember("descriptionLayout",(function(){return n.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-component-list-item-text-description">',"</div>\n\t\t\t"])),n.Text.encode(e.options.description))}))}},{key:"setDescription",value:function t(e){this.getDescriptionLayout().textContent=e}},{key:"getDescription",value:function t(){return this.getDescriptionLayout().innerText}},{key:"getEditButtonLayout",value:function t(){var e=this;return this.cache.remember("editButtonLayout",(function(){var t=new s.IconButton({type:s.IconButton.Types.edit,onClick:e.onEditButtonClick,title:i.Loc.getMessage("LANDING_UI_COMPONENT_LIST_ITEM_EDIT_TITLE")});return t.getLayout()}))}},{key:"onEditButtonClick",value:function t(e){e.preventDefault();var n=new o.BaseEvent;this.emit("onEdit",n);if(!n.isDefaultPrevented()){if(!this.isOpened()){this.open()}else{this.close()}}}},{key:"getRemoveButtonLayout",value:function t(){var e=this;return this.cache.remember("removeButtonLayout",(function(){var t=new s.IconButton({type:s.IconButton.Types.remove,onClick:e.onRemoveButtonClick,title:i.Loc.getMessage("LANDING_UI_COMPONENT_LIST_ITEM_REMOVE_TITLE")});return t.getLayout()}))}},{key:"onRemoveButtonClick",value:function t(e){e.preventDefault();n.Dom.remove(this.getLayout());this.emit("onRemove")}},{key:"getHeaderLayout",value:function t(){var e=this;return this.cache.remember("headerLayout",(function(){return n.Tag.render(c||(c=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-component-list-item-header">\n\t\t\t\t\t','\n\t\t\t\t\t<div class="landing-ui-component-list-item-text">\n\t\t\t\t\t\t',"\n\t\t\t\t\t\t",'\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="landing-ui-component-list-item-actions">\n\t\t\t\t\t\t<div class="landing-ui-component-list-item-actions-custom">\n\t\t\t\t\t\t\t',"\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t","\n\t\t\t\t\t\t","\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t"])),e.options.draggable?e.getDragButtonLayout():"",e.getTitleLayout(),e.getDescriptionLayout(),e.getActionsButtons().map((function(t){return t.getLayout()})),e.options.editable?e.getEditButtonLayout():"",e.options.removable?e.getRemoveButtonLayout():"")}))}},{key:"getBodyLayout",value:function t(){return this.cache.remember("bodyLayout",(function(){return n.Tag.render(p||(p=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-component-list-item-body"></div>\n\t\t\t'])))}))}},{key:"getLayout",value:function t(){var e=this;return this.cache.remember("layout",(function(){return n.Tag.render(d||(d=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div \n\t\t\t\t\tclass="landing-ui-component-list-item" \n\t\t\t\t\tdata-id="','"\n\t\t\t\t\tdata-type="','"\n\t\t\t\t\tdata-style="','"\n\t\t\t\t>\n\t\t\t\t\t',"\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),e.options.id,e.options.type,e.options.isSeparator?"separator":"item",e.getHeaderLayout(),e.getBodyLayout())}))}},{key:"open",value:function t(){n.Dom.addClass(this.getLayout(),"landing-ui-component-list-item-opened");if(!n.Type.isStringFilled(this.getBodyLayout().innerHTML)){if(this.options.form){n.Dom.append(this.options.form.getLayout(),this.getBodyLayout());this.options.form.subscribe("onChange",this.onFormChange)}}}},{key:"isOpened",value:function t(){return n.Dom.hasClass(this.getLayout(),"landing-ui-component-list-item-opened")}},{key:"close",value:function t(){n.Dom.removeClass(this.getLayout(),"landing-ui-component-list-item-opened")}},{key:"onFormChange",value:function t(){this.emit("onFormChange")}},{key:"setId",value:function t(e){n.Dom.attr(this.getLayout(),"data-id",e)}},{key:"getId",value:function t(){return n.Dom.attr(this.getLayout(),"data-id")}},{key:"getValue",value:function t(){var e={name:this.options.id};if(n.Type.isStringFilled(this.options.type)){e.type=this.options.type}if(this.options.form){var o=this.options.form.serialize();Object.assign(e,o)}if(this.options.content){e.content=this.options.content}if(this.options.sourceOptions){var i=n.Runtime.clone(this.options.sourceOptions);Object.entries(i).forEach((function(t){var o=babelHelpers.slicedToArray(t,2),a=o[0],s=o[1];if(n.Type.isArray(s)&&n.Type.isArray(e[a])){delete i[a]}}));return n.Runtime.merge(i,e)}return e}}]);return e}(o.EventEmitter);t.ListItem=m})(this.BX.Landing.UI.Component=this.BX.Landing.UI.Component||{},BX,BX,BX.Event,BX.Landing,BX.Landing.UI.Form,BX.Landing.UI.Component,BX.Landing.UI.Component);
//# sourceMappingURL=listitem.bundle.map.js